<template>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        货架管理
        <small>管理您仓库中的货架</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-university"></i> 货架管理</a></li>
        <li class="active">添加货架</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">添加货架</h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <form role="form">
                <!-- text input -->
                <div class="form-group">
                  <label for="rackName">货架名称</label>
                  <input id="rackName" class="form-control" placeholder="请输入货架名称" type="text">
                  <input style="display: none">
                </div>
                <div>
                  <p id="message" class="alert alert-danger hidden">message</p>
                </div>
              </form>
            </div>
            <div class="box-footer">
              <button class="btn btn-primary" @click="add">点击提交</button>
            </div>
            <!-- /.box-body -->
          </div>
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
</template>

<script>
export default {
  name: "AddRack",
  methods: {
    add() {
      let rackId = this.GLOBAL.appData.rackList.length + 1;
      let rackName = document.getElementById("rackName");
      if (rackName.value === "") {
        this.$message.warning("货架名不得为空");
      } else {
        this.GLOBAL.appData.rackList.push({
          "id": rackId,
          "name": rackName.value
        })
        this.$message.success("成功添加货架");
        this.$router.push("/main/rackData");
      }
    }
  }
}
</script>

<style scoped>

</style>